<form class = "layui-form ajax _form" action="{:url('')}" method="post">
    <input type="hidden" name="id" value="{$one.id}"/>
    <div class = "layui-form-item">
        <label class = "layui-form-label require">图片</label>
        <div class = "layui-input-block">
            <input type="hidden" name="path" value="{$one.path}" id = "path" required lay-verify = "required" />
            <div class = "image-item" style="background-image: url({$one.path})" id = "img">

            </div>
        </div>
    </div>
    <div class = "layui-form-item">
        <label class = "layui-form-label require">链接地址</label>
        <div class = "layui-input-block">
            <input type="text" name="link" value="{$one.link}" class = "layui-input" required lay-verify = "required"/>
        </div>
    </div>
    <div class = "layui-form-item">
        <button class = "layui-btn layui-btn-success">提交</button>
    </div>
</form>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#img' //绑定元素
            ,url: "{:url('home/file/upload')}" //上传接口
            ,done: function(res){
                if(res.code == 0) {
                    $("#path").val(res.msg);
                    $("#img").css("background-image","url(" + res.msg + ")");
                }
            }
            ,error: function(){
                //请求异常回调
                alert("上传文件失败")
            }
        });
    });
</script>